package com.french.numbers;

import com.french.numbers.R;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;


public class Mistake extends Activity implements OnClickListener {

	private String correctAnswerNumber = null;
	private String currentCorrectAnswer = null;
	private String number1 = null;
	private String number2 = null;
	private String number1Text = null;
	private String number2Text = null;
	private String expression = null;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    	setContentView(R.layout.mistake);
    	
        SharedPreferences settings = getSharedPreferences("Com.numbers.learn", 0);
        this.correctAnswerNumber = settings.getString("correctAnswerNumber",correctAnswerNumber);
        this.currentCorrectAnswer = settings.getString("currentCorrectAnswer",currentCorrectAnswer);
        this.number1 = settings.getString("number1",number1);
        this.number2 = settings.getString("number2",number2);
        this.expression = settings.getString("expression",expression);
        this.number1Text = settings.getString("number1Text",number1Text);
        this.number2Text = settings.getString("number2Text",number2Text);
    	
        TextView number1 = (TextView) findViewById(R.id.mistake_number1);
        TextView number2 = (TextView) findViewById(R.id.mistake_number2);
        TextView answer = (TextView) findViewById(R.id.mistake_answer);
        TextView translationNumber1 = (TextView) findViewById(R.id.mistake_translationNumber1);
        TextView translationNumber2 = (TextView) findViewById(R.id.mistake_translationNumber2);
        TextView translationAnswer = (TextView) findViewById(R.id.mistake_translationAnswer);
        TextView wholeExpression = (TextView) findViewById(R.id.mistake_wholeExpression);
        
        translationNumber1.setText(this.number1);
        translationNumber2.setText(this.number2);
        translationAnswer.setText(this.correctAnswerNumber);
        number1.setText(this.number1Text);
        number2.setText(this.number2Text);
        answer.setText(this.currentCorrectAnswer);
        wholeExpression.setText(expression);
    	
    	Button continueTraining = (Button) findViewById(R.id.mistake_continueTraining);
    	continueTraining.setOnClickListener(this);
    }
	
	@Override
	public void onClick(View v) {
    	Intent myIntent = new Intent(Mistake.this, Training.class);
    	Mistake.this.startActivity(myIntent);
    	Mistake.this.finish();

	}
	
}
